home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 2 / Macwelt DVD 2.cdr / Audio-Video-Multimedia / macos9 / Athena CL 1.0.13 / libATH / ATHorc.py / ATHorc.py
Encoding:
Text File  |  2002-03-15  |  43.3 KB  |  1,176 lines  |  [TEXT/Pyth]

  1. # ATHorc.py
  2. #-----------------------------------------------------------------||||||||||||--
  3. # Copyright (c) 2001 Christopher Ariza.
  4. # athenaCL comes with ABSOLUTELY NO WARRANTY;
  5. # for details see waranty information within athenaObj.py.
  6. # This is free software, and you are welcome to redistribute it under certain  
  7. # conditions; for details see copyright information within athenaObj.py.
  8. #-----------------------------------------------------------------||||||||||||--
  9.  
  10. import time
  11.  
  12. #-----------------------------------------------------------------||||||||||||--
  13. # this file is a combination of orc.py and ATHorc.orc
  14. # rather than use a built score, now scores are dynamically create
  15. # from version 1.0.11 on.
  16.  
  17.  
  18. class orcBuilder:
  19.    instrNumbers = (2,3,4,5,6,7,9,10,11,12,13,20,21,22,30,40)
  20.  
  21.    orcTitle = ';' + ('-'*65) + ('|'*12) + ('-'*2) + '\n' + ';athenaCL orchestra\n'
  22.    orcTitle = orcTitle + ';www.flexatone.com/athenaCL\n'
  23.    orcTitle = orcTitle + ';orchestra created on: %r\n' % time.asctime(time.localtime(time.time()))
  24.    orcTitle = orcTitle + ';' + ('-'*65) + ('|'*12) + ('-'*2) + '\n' + ';athenaCL orchestra\n'
  25.  
  26.    orcHeaderMono = '''
  27. sr     = 44100
  28. kr     = 4410
  29. ksmps  = 10
  30. nchnls = 1
  31. '''
  32.    orcHeaderStereo = '''
  33. sr     = 44100
  34. kr     = 4410
  35. ksmps  = 10
  36. nchnls = 2
  37. '''
  38.    orcHeaderQuad = '''
  39. sr     = 44100
  40. kr     = 4410
  41. ksmps  = 10
  42. nchnls = 4
  43. '''
  44.    scoFtables = '''
  45. ;f-tables
  46.    f1  0 4096  10 1                                         ; sine wave
  47.    f2  0 1025   5 1 1024 .002                               ; risset bell
  48.    f3  0 16384 10 1                                         ; risset bell
  49.    f4  0 2048  10 1 .5 .3 .25 .2 .167 .14 .125 .111         ; Sawtooth 
  50.    f5  0 2048  10 1 0  .3  0   .2  0  .14  0   .111         ; Square
  51.    f6  0 2048  10 1 1 1 1 .7 .5 .3 .1                       ; Pulse
  52.    f7  0 2048  19 .5 1 270 1                                ; sigmoid rise
  53.    f8  0 4097  7 0 100 .1 300 3 600 1 3000 .01 96 0         ; buzz f-card
  54.    f9  0 256   10 1                                         ; low rez sine
  55.    f13 0 1024  8 -.8 42 -.78  400 -.7 140 .7  400 .78 42 .8 ; distortion table
  56.  
  57. ;f-tables--i20
  58.    ;exponentially decaying amplitude envelope for carrier signal
  59.    f201      0       512     5       1   512  .001     
  60.    ;amplitude envelope for frequency modulation    
  61.    f202      0       512     7       1   64    0    448  0  
  62.    ;waveform of carrier signal   
  63.    f203      0       512     9       1   1     0            
  64.  
  65. ;f-tables--i21
  66.    f210 0  512  10  1                            ; carriers
  67.    f211 0 1024  5  .0001 200 1 674 1 150 .0001   ; amplitude envelope
  68.    f212 0 1024  5  1 1024 .0001                  ; index envelope
  69.  
  70. ;f-tables--i22
  71.    f231 0 512 7   1  64  0   448  0              ; index envelope
  72.    f251 0 513 5  .8  113 1   10   1 390 .0001    ; amplitude envelope
  73. '''
  74.  
  75.  
  76.    # instrObjDict is built for each command: bad?!
  77.    def constructOrc(self, noChannels=2):
  78.       self.orc = self.orcTitle
  79.       self.noChannels = noChannels
  80.       if self.noChannels   == 1:
  81.          self.orc  = self.orc  + self.orcHeaderMono
  82.       elif self.noChannels == 2:
  83.          self.orc  = self.orc  + self.orcHeaderStereo
  84.       elif self.noChannels == 4:
  85.          self.orc  = self.orc  + self.orcHeaderQuad
  86.       self.instrObjDict = {}
  87.       for number in self.instrNumbers:
  88.          self.instrObjDict[('i%i' % number)] = eval(('instr%i()' % number))
  89.          instrObj = self.instrObjDict[('i%i' % number)]
  90.          self.orc = self.orc + instrObj.buildInstrDef(noChannels)
  91.       return self.orc
  92.  
  93.    def clearOrc(self, noChannels):
  94.       if self.instrObjDict:
  95.          del self.instrObjDict
  96.  
  97.    def getInstrInfo(self):
  98.       'returns a dictionary of instrNo : (Name, pNo)'
  99.       self.instrObjDict = {}
  100.       instInfoDict = {}
  101.       for number in self.instrNumbers:
  102.          self.instrObjDict[('i%i' % number)] = eval(('instr%i()' % number))
  103.          instrObj = self.instrObjDict[('i%i' % number)]
  104.          instInfoDict[number] = (instrObj.name, instrObj.pmtrFields)
  105.       return instInfoDict
  106.  
  107.    def getInstrPreset(self, iNo):
  108.       'returns a dictionary of default values'
  109.       instrObject = eval(('instr%i()' % iNo))
  110.       presetDict = instrObject.getPresetDict()
  111.       return presetDict
  112.  
  113.    def getInstrName(self, iNo):
  114.       'returns a dictionary of default values'
  115.       instrObject = eval(('instr%i()' % iNo))
  116.       return instrObject.name
  117.  
  118. #-----------------------------------------------------------------||||||||||||--
  119. class instrShell:
  120.    # outputs expect and instrument to have a single final signal, calld "aMixSig
  121.    # this bit of codes gets appended to end of inst def
  122.    monoOutput = '''
  123.    ;--stereo panning around 90 degrees
  124.    out             aMixSig
  125.    endin
  126. '''
  127.    stereoOutput = '''
  128.    ;--stereo panning around 90 degrees
  129.    iCirclePan      = 90.0 * ipan         ; scale 90 with values from 0 to 1
  130.    kdegree         line      iCirclePan, p3, iCirclePan
  131.    kdistance       line      1, p3, 1    ; used to distance reverb, need a constant 1
  132.    asig1, asig2    locsig    aMixSig, kdegree, kdistance, 0.0
  133.    outs            asig1, asig2
  134.    endin
  135. '''
  136.    quadOutput = '''
  137.    ;--quad panning around 360 degrees
  138.    iCirclePan                  = 360.0 * ipan         ; scale 90 with values from 0 to 1
  139.    kdegree                     line      iCirclePan, p3, iCirclePan
  140.    kdistance                   line      1, p3, 1    ; used to distance reverb, need a constant 1
  141.    asig1, asig2, asig3, asig4  locsig    aMixSig, kdegree, kdistance, 0.0
  142.    outq                        asig1, asig2, asig3, asig4
  143.    endin
  144. '''
  145.    # defined in each sub-classed instrument
  146.    #inumber     = 12
  147.    #name       = 'noiseFiltered'
  148.    #info       = 'A noisy instrument with with a filter.'
  149.    #pmtrFields = 8 # this is the base number
  150.    #pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  151.    #author     = '' # attribution
  152.    #orcCode = ''
  153.    #scoSample ''
  154.  
  155.    def __init__(self):
  156.       pass
  157.  
  158.    def getInstrHeader(self):
  159.       return '\n;--||||||||||||--i%i--%s' % (self.inumber, self.name)
  160.  
  161.    def buildInstrDef(self, noChannels):
  162.       'returns a string of all the code needed for this instrument'
  163.       orcString = self.getInstrHeader()
  164.       orcString = orcString + self.orcCode
  165.       self.noChannels = noChannels
  166.       if self.noChannels   == 1:
  167.          orcString = orcString + self.monoOutput
  168.       elif self.noChannels == 2:
  169.          orcString = orcString + self.stereoOutput
  170.       elif self.noChannels == 4:
  171.          orcString = orcString + self.quadOutput
  172.       return orcString
  173.  
  174.    def getPresetDict(self):
  175.       presetDict = {}
  176.       # some fixed values:
  177.       presetDict['fieldQ'] = ('basketGen', 'orderedCyclic', [0])
  178.       presetDict['auxQ']   = (0,) # an empty tuple is default aux value
  179.  
  180.       # get values from self.default
  181.       auxDict = {}
  182.       for key in self.default.keys(): # isolate pmtr fields
  183.          if key[:4] == 'pmtr': # rename pmtr keys to a single auxQ list of entries
  184.             newKey  = key[4:] # this is the number as pmtr field
  185.             newKey  = eval(newKey) - (self.pmtrFields + 1) # make pmtr7 == aux0
  186.             auxDict[newKey] = self.default[key]
  187.          else:
  188.             presetDict[key] = self.default[key]
  189.       auxKeyList = auxDict.keys() # get numbers
  190.       if self.pmtrFields > 6: # 6 is standard size
  191.          auxKeyList.sort()
  192.          auxQ = [] # pack all into a list
  193.          for keyNo in auxKeyList: # gets number in order
  194.             auxQ.append(auxDict[keyNo])
  195.          presetDict['auxQ'] = auxQ
  196.       return presetDict
  197.  
  198. #-----------------------------------------------------------------||||||||||||--
  199. #-----------------------------------------------------------------||||||||||||--
  200. # these classes inherit all functions from instrShell
  201.  
  202.  
  203.  
  204. #-----------------------------------------------------------------||||||||||||--
  205. class instr2(instrShell):
  206.    inumber    = 2
  207.    name       = 'additiveBellBright'
  208.    info       = 'A simple bell made with 12 partials, each with their own envelope, then mixed together. Based on design by C. Risset.'
  209.    pmtrFields = 6  # this is the base number
  210.    pmtrInfo   = {} # infor for aux perameters (greater than six)
  211.    default    = {
  212.                  'rhythmQ' : ((16, 1), (16, 3)),        #(division1, #), (division2, #)
  213.                  'octQ'    : ([7,8], 'randomChoice'),              #([list of registers], 0=random/1=ordered) (8.00 = C4)
  214.                  'ampQ'    : (60,70, 1, 'linearUp'),            #lowest, highest, increment (in db), direction
  215.                  'panQ'    : (.20, .80, .08, 'linearDown'),        #lowest, highest(1 max), increment, direction
  216.                 } 
  217.    author     = '' # attribution
  218.    orcCode = '''
  219. instr 2
  220.    ipan   = p6
  221.    idur1  = p3
  222.    iamp1  = ampdb(p4)
  223.    ifreq1 = (cpspch(p5) * .56)
  224.    idur2  = (p3 * .9)
  225.    iamp2  = (ampdb(p4) * .67)
  226.    ifreq2 = (cpspch(p5))
  227.    idur3  = (p3 * .65)
  228.    iamp3  = (ampdb(p4))
  229.    ifreq3 = (cpspch(p5) * .92)
  230.    idur4  = (p3 * .55)
  231.    iamp4  = (ampdb(p4)  * 1.8)
  232.    ifreq4 = (cpspch(p5) * 2.62)        
  233.    idur5  = (p3 * .35)
  234.    iamp5  = (ampdb(p4)  * 2.67)
  235.    ifreq5 = (cpspch(p5) * 1.19)
  236.    idur6  = (p3 * .35)
  237.    iamp6  = (ampdb(p4)  * 1.67)
  238.    ifreq6 = (cpspch(p5) * 1.7)
  239.    idur7  = (p3 * .25)
  240.    iamp7  = (ampdb(p4)  * 1.46)
  241.    ifreq7 = (cpspch(p5) * 2)
  242.    idur8  = (p3 * .2)
  243.    iamp8  = (ampdb(p4)  * 1.33)
  244.    ifreq8 = (cpspch(p5) * 2.74)
  245.    idur9  = (p3 * .15)
  246.    iamp9  = (ampdb(p4)  * 1.33)
  247.    ifreq9 = (cpspch(p5) * 3)
  248.    idur10 = (p3 * .1)
  249.    iamp10 = (ampdb(p4))
  250.    ifreq10= (cpspch(p5) * 3.76)
  251.    idur11 = (p3 * .075)
  252.    iamp11 = (ampdb(p4)  * 1.33)
  253.    ifreq11= (cpspch(p5) * 4.07)
  254.    
  255.       ;create oscilators for each partial
  256.    koscil1 oscil1i    0, iamp1, idur1, 2
  257.    aoscili1 oscili    koscil1, ifreq1, 3
  258.    koscil2 oscil1i    0, iamp2, idur2, 2
  259.    aoscili2 oscili    koscil2, ifreq2, 3
  260.    koscil3 oscil1i    0, iamp3, idur3, 2
  261.    aoscili3 oscili    koscil3, ifreq3, 3
  262.    koscil4 oscil1i    0, iamp4, idur4, 2
  263.    aoscili4 oscili    koscil4, ifreq4, 3
  264.    koscil5 oscil1i    0, iamp5, idur5, 2
  265.    aoscili5 oscili    koscil5, ifreq5, 3
  266.    koscil6 oscil1i    0, iamp6, idur6, 2
  267.    aoscili6 oscili    koscil6, ifreq6, 3
  268.    koscil7 oscil1i    0, iamp7, idur7, 2
  269.    aoscili7 oscili    koscil7, ifreq7, 3
  270.    koscil8 oscil1i    0, iamp8, idur8, 2
  271.    aoscili8 oscili    koscil8, ifreq8, 3
  272.    koscil9 oscil1i    0, iamp9, idur9, 2
  273.    aoscili9 oscili    koscil9, ifreq9, 3
  274.    koscil10 oscil1i   0, iamp10, idur10, 2
  275.    aoscili10 oscili   koscil10, ifreq10, 3
  276.    koscil11 oscil1i   0, iamp11, idur11, 2
  277.    aoscili11 oscili   koscil11, ifreq11, 3
  278.  
  279.    ;output assignments
  280.    aMixSig         = (aoscili1+aoscili2+aoscili3+aoscili4+aoscili5 + aoscili6+aoscili7+aoscili8+aoscili9+aoscili10+aoscili11)
  281. '''
  282.    scoSample = '''
  283. ;p1    p2    p3     p4    p5      p6
  284. ;inst  start dur    amp   PCH     pan
  285. i2    12.00 1.000  97    7.09   .5
  286. i2    12.10 1.000  84    8.09   .5
  287. '''
  288.  
  289. #-----------------------------------------------------------------||||||||||||--
  290. class instr3(instrShell):
  291.    inumber     = 3
  292.    name       = 'sineWaveDrone'
  293.    info       = 'A simple sine wave drone.'
  294.    pmtrFields = 6 # total number
  295.    pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  296.    default    = {
  297.                  'rhythmQ' : ((4, 5), (4, 5)),
  298.                  'octQ'    : ([7,8],   'randomChoice'),
  299.                  'ampQ'    : (60,70, 1, 'linearUp') ,
  300.                  'panQ'    : (.60, 1.0, .08, 'linearDown'),
  301.                 } 
  302.    author     = 'athenaCL native' # attribution
  303.    orcCode = '''
  304. instr 3
  305.    idur  = p3
  306.    iamp  = ampdb(p4)
  307.    ifreq = cpspch(p5)
  308.    ipan  = p6
  309.    
  310.    ;generate aplitude envelope
  311.    ;             amp   attack        dur    release
  312.    k1   linen   iamp,  (idur * .18), idur,  (idur*.19)
  313.    
  314.    ;generate vibrato envelope                       
  315.    irel  = 1.00                   ; set vibrato release time
  316.    idel1 = idur-(.25 * idur)      ; calculate initial delay (% of dur)
  317.    isus  = idur - (idel1 - irel)  ; calculate remaining duration                       
  318.    idep  = 2                 ; vibrato depth (1-9 are good)
  319.    irat  = 1                 ; vibrato rate  (1-9 are good)
  320.    ;                    
  321.    ;linseg does delay, osicl does vibrato, k4 uses pulse wave             
  322.    k3 linseg  0, idel1, idep, isus, idep, irel, 0  
  323.    k2 oscil   k3, irat, 1
  324.    k4 oscil   k3, (irat * .666), 6
  325.    
  326.    ;generate oscilator using k1, add vibrato w/k2, k4
  327.    ;            amp       freq                  waveshape
  328.    a1   oscil   k1,       (ifreq + k2),               1      
  329.    a2   oscil  (k1 * .8), ((ifreq * .5) + (k4 * .5)), 1
  330.    
  331.    aMixSig         = (a1 + a2)
  332. '''
  333.    scoSample = '''
  334. ;p1   p2     p3     p4   p5    p6
  335. ;inst start  dur    amp  PCH  pan
  336. i3    68.00 00.500 95   5.08  .5
  337. i3    68.66 00.500 75   6.11  .5
  338. '''
  339.  
  340. #-----------------------------------------------------------------||||||||||||--
  341. class instr4(instrShell):
  342.    inumber     = 4
  343.    name       = 'additiveBellDark'
  344.    info       = 'A simple bell made with 12 partials, each with their own envelope, then mixed together. Based on design by C. Risset.'
  345.    pmtrFields = 6 # this is the base number
  346.    pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  347.    default    = {
  348.                  'rhythmQ' : ((4, 5), (4, 5)),
  349.                  'octQ'    : ([7,8], 'randomChoice'),
  350.                  'ampQ'    : (60,70, 1, 'linearUp') ,
  351.                  'panQ'    : (.60, 1.0, .08, 'linearDown'),
  352.                 } 
  353.    author     = '' # attribution
  354.    orcCode = '''
  355. ; "INSTRUMENT 4, bell"
  356. instr 4
  357.    ipan   = p6
  358.    idur1  = (p3 * .5)
  359.    iamp1  = (ampdb(p4)  * .5)
  360.    ifreq1 = (cpspch(p5) * .2)
  361.    idur2  = (p3 * .5)
  362.    iamp2  = (ampdb(p4)  * .7)
  363.    ifreq2 = (cpspch(p5) * .5)
  364.    idur3  = (p3 * .5)
  365.    iamp3  = (ampdb(p4)  * 1)
  366.    ifreq3 = (cpspch(p5) * .8)
  367.    idur4  = (p3 * .6)
  368.    iamp4  = (ampdb(p4)  * 1.2)
  369.    ifreq4 = (cpspch(p5) * 1)
  370.    idur5  = (p3 * .7)
  371.    iamp5  = (ampdb(p4)  * 1.5)
  372.    ifreq5 = (cpspch(p5) * 1.2)
  373.    idur6  = (p3 * 1.2)
  374.    iamp6  = (ampdb(p4)  * 1.5)
  375.    ifreq6 = (cpspch(p5) * 1.5)
  376.    idur7  = (p3 * 1.2)
  377.    iamp7  = (ampdb(p4)  * 1.6)
  378.    ifreq7 = (cpspch(p5) * 2)
  379.    idur8  = (p3 * 1.2)
  380.    iamp8  = (ampdb(p4)  * 1.7)
  381.    ifreq8 = (cpspch(p5) * 3)
  382.    idur9  = (p3 * 1.3)
  383.    iamp9  = (ampdb(p4)  * 1.8)
  384.    ifreq9 = (cpspch(p5) * 3)
  385.    idur10 = (p3 * 1.4)
  386.    iamp10 = (ampdb(p4)  * 1.9)
  387.    ifreq10= (cpspch(p5) * 4.5)
  388.    idur11 = (p3 * 1.5)
  389.    iamp11 = (ampdb(p4)  * 2)
  390.    ifreq11= (cpspch(p5) * 4.8)
  391.    
  392.    koscil1 oscil1i   0, iamp1, idur1, 2
  393.    aoscili1 oscili   koscil1, ifreq1, 3
  394.    koscil2 oscil1i   0, iamp2, idur2, 2
  395.    aoscili2 oscili   koscil2, ifreq2, 3
  396.    koscil3 oscil1i   0, iamp3, idur3, 2
  397.    aoscili3 oscili   koscil3, ifreq3, 3
  398.    koscil4 oscil1i   0, iamp4, idur4, 2
  399.    aoscili4 oscili   koscil4, ifreq4, 3
  400.    koscil5 oscil1i   0, iamp5, idur5, 2
  401.    aoscili5 oscili   koscil5, ifreq5, 3
  402.    koscil6 oscil1i   0, iamp6, idur6, 2
  403.    aoscili6 oscili   koscil6, ifreq6, 3
  404.    koscil7 oscil1i   0, iamp7, idur7, 2
  405.    aoscili7 oscili   koscil7, ifreq7, 3
  406.    koscil8 oscil1i   0, iamp8, idur8, 2
  407.    aoscili8 oscili   koscil8, ifreq8, 3
  408.    koscil9 oscil1i   0, iamp9, idur9, 2
  409.    aoscili9 oscili   koscil9, ifreq9, 3
  410.    koscil10 oscil1i   0, iamp10, idur10, 2
  411.    aoscili10 oscili   koscil10, ifreq10, 3
  412.    koscil11 oscil1i   0, iamp11, idur11, 2
  413.    aoscili11 oscili   koscil11, ifreq11, 3
  414.  
  415.    aMixSig         = (aoscili1+aoscili2+aoscili3+aoscili4+aoscili5 + aoscili6+aoscili7+aoscili8+aoscili9+aoscili10+aoscili11)
  416. '''
  417.    scoSample = '''
  418. ;p1    p2    p3     p4    p5      p6
  419. ;inst  start dur    amp   PCH     pan
  420. i2    12.00 1.000  97    7.09   .5
  421. i2    12.10 1.000  84    8.09   .5
  422.  
  423. '''
  424.  
  425. #-----------------------------------------------------------------||||||||||||--
  426. class instr5(instrShell):
  427.    inumber     = 5
  428.    name       = 'sawWaveDrone'
  429.    info       = 'A simple bell made with 12 partials, each with their own envelope, then mixed together. Based on design by C. Risset.'
  430.    pmtrFields = 6  # total
  431.    pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  432.    default    = {
  433.                  'rhythmQ' : ((2, 4), (2, 1)), 
  434.                  'octQ'    : ([7,8], 'randomChoice'),
  435.                  'ampQ'    : (60,70, 2, 'linearUpDown'),
  436.                  'panQ'    : (.20, .60, .08, 'linearDown'), 
  437.                 } 
  438.    author     = '' # attribution
  439.    orcCode = '''
  440. instr 5
  441.    idur  = p3
  442.    iamp  = ampdb(p4)
  443.    ifreq = cpspch(p5)
  444.    ipan  = p6
  445.    
  446.    ;generate aplitude envelope
  447.    ;          amp    attack       dur   release
  448.    k1 linen   iamp, (idur * .18), idur, (idur *.19)
  449.    
  450.    ;generate vibrato envelope                       
  451.    irel  = 1.00                   ; set vibrato release time
  452.    idel1 = idur - (.25 * idur)    ; calculate initial delay (% of dur)
  453.    isus  = idur - (idel1 - irel)  ; calculate remaining duration                       
  454.    idep  = 2                      ; vibrato depth (1-9 are good)
  455.    irat  = 1                      ; vibrato rate  (1-9 are good)
  456.    ;                    
  457.    ;linseg does delay, osicl does vibrato, k4 uses pulse wave             
  458.    k3 linseg  0, idel1, idep, isus, idep, irel, 0  
  459.    k2 oscil   k3, irat,        1
  460.    k4 oscil   k3, (irat*.666), 6
  461.    
  462.    ;generate oscilator using k1, add vibrato w/k2, k4
  463.    ;          amp     freq                   waveshape
  464.    a1 oscil   k1,     (ifreq + k2),              4      
  465.    a2 oscil  (k1*.8), ((ifreq * .5) + (k4 *.5)), 1
  466.  
  467.    aMixSig         = (a1+a2)
  468. '''
  469.    scoSample = '''
  470. ;p1    p2    p3     p4    p5      p6
  471. inst  start dur    amp   PCH     pan
  472. i5    12.00 1.000  95    7.09   .5
  473. i5    12.10 1.000  84    8.09   .5
  474. '''
  475.  
  476. #-----------------------------------------------------------------||||||||||||--
  477. class instr6(instrShell):
  478.    inumber     = 6
  479.    name       = 'pluckFormant'
  480.    info       = 'A pluck that slowly morphs into a vocal, formant derived sound.'
  481.    pmtrFields = 16 # this is the base number
  482.    pmtrInfo   = {
  483.                  'pmtr7'   : 'ipluckamp, % of total amp, 1=dB amp as in p4',
  484.                  'pmtr8'   : 'ipluckdur, % of total dur, 1=entire dur of note',
  485.                  'pmtr9'   : 'ifmamp, % of total amp, 1=dB amp as in p4', 
  486.                  'pmtr10'  : 'ifmrise, % of total dur, 1=entire dur of note', 
  487.                  'pmtr11'  : 'ifmdec, % of total duration', 
  488.                  'pmtr12'  : 'index',   
  489.                  'pmtr13'  : 'ivibdepth',  
  490.                  'pmtr14'  : 'ivibrate',
  491.                  'pmtr15'  : 'iformantamp',  
  492.                  'pmtr16'  : 'iformantrise',   
  493.                 } # holds discription, preset for each pmtr in a dictionary
  494.    default    = {
  495.                  'rhythmQ' : ((2, 3), (2, 9)), 
  496.                  'octQ'    : ([7,8],   'randomChoice'),
  497.                  'ampQ'    : (60,70, 4, 'linearDown') ,
  498.                  'panQ'    : (.30, .70, .08, 'linearDown'), 
  499.                  'pmtr7'   : (.8, .9, .05, 'linearUp'),
  500.                  'pmtr8'   : (.2, .4, .05, 'linearUp'),
  501.                  'pmtr9'   : (.7, .8, .05, 'linearUp'), 
  502.                  'pmtr10'  : (.2, .35, .05, 'linearUp'), 
  503.                  'pmtr11'  : (.3, .40, .05, 'linearUp'), 
  504.                  'pmtr12'  : (6, 8, 1, 'linearUpDown'),   
  505.                  'pmtr13'  : (1, 1, 0, 'linearUpDown'),  
  506.                  'pmtr14'  : (4, 6, 1, 'linearUp'),
  507.                  'pmtr15'  : (3, 3, 0, 'linearUpDown'),  
  508.                  'pmtr16'  : (.5, .8, .1, 'linearUp'),   
  509.                 } 
  510.    author     = '' # attribution
  511.    orcCode = '''
  512. instr 6                         
  513.    iamp         = ampdb(p4) / 2  ; amplitude, scaled for two sources
  514.    ifreq        = cpspch(p5)
  515.    
  516.    ipan         = p6  
  517.    ipluckamp    = p7              ; % of total amp, 1=dB amp as in p4
  518.    ipluckdur    = p8 * p3         ; % of total dur, 1=entire dur of note
  519.    ipluckoff    = p3 - ipluckdur
  520.    
  521.    ifmamp       = p9               ; % of total amp, 1=dB amp as in p4
  522.    ifmrise      = p10 * p3         ; % of total dur, 1=entire dur of note
  523.    ifmdec       = p11 * p3         ; % of total duration
  524.    ifmoff       = p3 - (ifmrise + ifmdec)
  525.    index        = p12
  526.    ivibdepth    = p13
  527.    ivibrate     = p14
  528.    iformantamp  = p15            ; % of total amp, 1=dB amp as in p4
  529.    iformantrise = p16 * p3       ; % of total dur, 1=entire dur of note
  530.    iformantdec  = p3 - iformantrise
  531.    
  532.    kpluck       linseg    ipluckamp, ipluckdur, 0, ipluckoff, 0
  533.    apluck1      pluck     iamp, ifreq, ifreq, 0, 1
  534.    apluck2      pluck     iamp, ifreq * 1.003, ifreq * 1.003, 0, 1
  535.    apluck       =         kpluck * (apluck1+apluck2)
  536.    
  537.    kfm          linseg    0, ifmrise, ifmamp, ifmdec, 0, ifmoff, 0
  538.    kndx         =         kfm * index
  539.    afm1         foscil    iamp, ifreq, 1, 7, kndx, 1
  540.    afm2         foscil    iamp, ifreq * 1.003, 1.003, 2.003, kndx, 1
  541.    afm          =         kfm * (afm1+afm2)
  542.    
  543.    kfrmnt       linseg    0, iformantrise, iformantamp, iformantdec, 0
  544.    kvib         oscil     ivibdepth, ivibrate, 1
  545.    afrmnt1      fof       iamp, ifreq + kvib, 650, 0, 40, .003, .017, .007, 4, 1, 7, p3
  546.    afrmnt2      fof       iamp, (ifreq*1.001)+kvib*.009, 650, 0, 40, .003,.017,.007, 10,1,7,p3
  547.    aformnt      =         kfrmnt * (afrmnt1+afrmnt2)
  548.  
  549.    aMixSig         = (apluck + afm + aformnt)
  550. '''
  551.    scoSample = '''
  552.                             ;values b/n 0 & 1.
  553.                             ;p6    p7    p8  p9   p10    p11  p12  p13   p14  p15   p16      
  554. ;ins st    dr   amp   PCH    pan   plkmp plkdr fmp fmris fmdec indx vbdp vbrt frmp fris
  555. i13 52.11  4    80   7.09  .5     .8   .3   .7   .2   .35    8   1   5   3   .5
  556. i13 53.44  4    80   7.09  .5     .8   .4   .7   .35  .35    7   1   6   3   .7
  557. i13 54.77  6    80   7.09  .5     .8   .3   .7   .2   .4     6   1   4   3   .6
  558. i13 56.00  8    80   7.09  .5     .8   .3   .7   .2   .4     6   1   5   3   .6
  559. '''
  560.  
  561. #-----------------------------------------------------------------||||||||||||--
  562. class instr7(instrShell):
  563.    inumber    = 7
  564.    name       = 'waveformVibrato'
  565.    info       = 'A waveform derived instrument that has vibrato controls.'
  566.    pmtrFields = 14 # total
  567.    pmtrInfo   = {
  568.                  'pmtr7'   : 'attack',
  569.                  'pmtr8'   : 'release rate',
  570.                  'pmtr9'   : 'vibrato depth',
  571.                  'pmtr10'  : 'vibrato delay',
  572.                  'pmtr11'  : 'vibrato fq',
  573.                  'pmtr12'  : 'start',
  574.                  'pmtr13'  : 'end',
  575.                  'pmtr14'  : 'xtime',
  576.                 } # holds discription, preset for each pmtr in a dictionary
  577.    default    = {
  578.                  'rhythmQ' : ((9, 6), (9, 2)), 
  579.                  'octQ'    : ([7,8],   'randomChoice'),
  580.                  'ampQ'    : (60,70, 4, 'linearDown') ,
  581.                  'panQ'    : (.30, .70, .08, 'linearDown'), 
  582.                  'pmtr7'   : (1, 4, 1, 'linearUp'),     
  583.                  'pmtr8'   : (2, 3, 1, 'linearUp'),    
  584.                  'pmtr9'   : (2, 4, 1, 'linearUp'),     
  585.                  'pmtr10'  : (2, 4, 1, 'linearUp'),       
  586.                  'pmtr11'  : (.2, 2, .1, 'linearUpDown'), 
  587.                  'pmtr12'  : (1, 6, 1, 'linearUpDown'),   
  588.                  'pmtr13'  : (1, 5, 1, 'linearUpDown'),   
  589.                  'pmtr14'  : (.6, .8, .01, 'linearUp'),  
  590.                 } 
  591.    author     = '' # attribution
  592.    orcCode = '''
  593. instr 7  
  594.    ipan   = p6
  595.                           
  596.    ifunc1 = p12                    ; initial waveform
  597.    ifunc2 = p13                    ; crossfade waveform
  598.    ifad1  = p3 - (p14 * p3)        ; calculate initial fade
  599.    ifad2  = p3 - ifad1             ; calculate remaining dur
  600.    irel   = .1                     ; set vibrato release
  601.    idel1  = p3 - (p11 * p3)        ; calculate initial delay
  602.    isus   = p3 - (idel1- irel)     ; calculate remaining dur
  603.    iamp   = ampdb(p4)
  604.    iscale = iamp * .166                              ; p4=amp
  605.    inote  = cpspch(p5)                               ; p5=freq
  606.    
  607.    k3  linseg    0, idel1, p10, isus, p10, irel, 0    ; p7=attack time
  608.    k2  oscil     k3, p9, 1                          ; p7=release time
  609.    k1  linen     iscale, p7, p3, p8                 ; p9=vib rate
  610.    a6  oscil     k1, inote*.5+k2, ifunc2            ; p10=vib depth
  611.    a5  oscil     k1, inote*1.25+k2, ifunc2          ; p11=vib delay (0-1)
  612.    a4  oscil     k1, inote+k2, ifunc2               ; p12=initial wave
  613.    a3  oscil     k1, inote*.997+k2, ifunc1          ; p13=cross wave
  614.    a2  oscil     k1, inote*1.003+k2, ifunc1         ; p14=fade time (0-1)
  615.    a1  oscil     k1, inote+k2, ifunc1   
  616.              
  617.    kfade  linseg 1, ifad1, 0, ifad2, 1
  618.    afunc1 = kfade * (a1+a2+a3)
  619.    afunc2 = (1 - kfade) * (a4+a5+a6)
  620.  
  621.    aMixSig         = (afunc1 + afunc2)
  622. '''
  623.    scoSample = '''
  624.  
  625. ;p1   p2    p3   p4   p5     p6   p7   p8   p9    p10    p11    p12    p13  p14
  626. ;inst start dur  amp  freq   pan  atk  rels vib   vib   vib    start  end  xtime
  627. ;               (dbs) (pch)           rate  depth delay  (f)
  628. i7    53    14   95   8.04  .5   3   3    2     4     .4     1      5    .8 
  629. i7    55    12   95   8.03  .5   2   3    4     3     .4     6      1    .8
  630. '''
  631.  
  632. #-----------------------------------------------------------------||||||||||||--
  633. class instr9(instrShell):
  634.    inumber     = 9
  635.    name       = 'additiveBellClear'
  636.    info       = 'A simple bell made with 12 partials, each with their own envelope, then mixed together. Based on design by C. Risset.'
  637.    pmtrFields = 6 # this is the base number
  638.    pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  639.    default    = {
  640.                  'rhythmQ' : ('loop', ((2,1,1),(2,3,1),(4,3,0))),                    #(division1, #), (division2, #)
  641.                  'octQ'    : ([7,8], 'randomChoice'),             #([list of registers], 0=random/1=ordered) (8.00 = C4)
  642.                  'ampQ'    : (60,70, 1, 'linearUp'),                #lowest, highest, increment (in db), direction
  643.                  'panQ'    : (.20, .80, .08, 'linearDown'),         #lowest, highest(1 max), increment, direction
  644.                 } 
  645.    author     = '' # attribution
  646.    orcCode = '''
  647. instr 9
  648.    ipan   = p6
  649.    
  650.    idur1  = p3
  651.    iamp1  = ampdb(p4)
  652.    ifreq1 = (cpspch(p5) * 1)
  653.    
  654.    idur2  = (p3 * .9)
  655.    iamp2  = (ampdb(p4)  * .80)
  656.    ifreq2 = (cpspch(p5) * 1.5)
  657.    
  658.    idur3  = (p3 * .70)
  659.    iamp3  = (ampdb(p4)  * .70)
  660.    ifreq3 = (cpspch(p5) * 2)
  661.    
  662.    idur4  = (p3 * .60)
  663.    iamp4  = (ampdb(p4)  * .80)
  664.    ifreq4 = (cpspch(p5) * 2.5)        
  665.    
  666.    idur5  = (p3 * .40)
  667.    iamp5  = (ampdb(p4)  * .55)
  668.    ifreq5 = (cpspch(p5) * 3)
  669.    
  670.    idur6  = (p3 * 1.05)
  671.    iamp6  = (ampdb(p4)  * .48)
  672.    ifreq6 = (cpspch(p5) * 4)
  673.    
  674.    idur7  = (p3 * .80)
  675.    iamp7  = (ampdb(p4)  * .40)
  676.    ifreq7 = (cpspch(p5) * 5)
  677.    
  678.    idur8  = (p3 * .65)
  679.    iamp8  = (ampdb(p4)  * .35)
  680.    ifreq8 = (cpspch(p5) * 6)
  681.    
  682.    idur9  = (p3 * .15)
  683.    iamp9  = (ampdb(p4)  * .30)
  684.    ifreq9 = (cpspch(p5) * 7)
  685.    
  686.    idur10 = (p3 * .90)
  687.    iamp10 = (ampdb(p4))
  688.    ifreq10= (cpspch(p5) * 8)
  689.    
  690.    idur11 = (p3 * .10)
  691.    iamp11 = (ampdb(p4)  * .28)
  692.    ifreq11= (cpspch(p5) * 9)
  693.    
  694.       ;create oscilators for each partial
  695.    koscil1 oscil1i    0, iamp1, idur1, 2
  696.    aoscili1 oscili    koscil1, ifreq1, 3
  697.    koscil2 oscil1i    0, iamp2, idur2, 2
  698.    aoscili2 oscili    koscil2, ifreq2, 3
  699.    koscil3 oscil1i    0, iamp3, idur3, 2
  700.    aoscili3 oscili    koscil3, ifreq3, 3
  701.    koscil4 oscil1i    0, iamp4, idur4, 2
  702.    aoscili4 oscili    koscil4, ifreq4, 3
  703.    koscil5 oscil1i    0, iamp5, idur5, 2
  704.    aoscili5 oscili    koscil5, ifreq5, 3
  705.    koscil6 oscil1i    0, iamp6, idur6, 2
  706.    aoscili6 oscili    koscil6, ifreq6, 3
  707.    koscil7 oscil1i    0, iamp7, idur7, 2
  708.    aoscili7 oscili    koscil7, ifreq7, 3
  709.    koscil8 oscil1i    0, iamp8, idur8, 2
  710.    aoscili8 oscili    koscil8, ifreq8, 3
  711.    koscil9 oscil1i    0, iamp9, idur9, 2
  712.    aoscili9 oscili    koscil9, ifreq9, 3
  713.    koscil10 oscil1i   0, iamp10, idur10, 2
  714.    aoscili10 oscili   koscil10, ifreq10, 3
  715.    koscil11 oscil1i   0, iamp11, idur11, 2
  716.    aoscili11 oscili   koscil11, ifreq11, 3
  717.  
  718.    ;output assignments
  719.    aMixSig         = (aoscili1+aoscili2+aoscili3+aoscili4+aoscili5 + aoscili6+aoscili7+aoscili8+aoscili9+aoscili10+aoscili11)
  720. '''
  721.    scoSample = '''
  722.  
  723. ;p1    p2    p3     p4    p5      p6
  724. ;inst  start dur    amp   PCH     pan
  725. i9    12.00 1.000  97    7.09   .5
  726. i9    12.10 1.000  84    8.09   .5
  727. '''
  728. #-----------------------------------------------------------------||||||||||||--
  729. class instr10(instrShell):
  730.    inumber     = 10
  731.    name       = 'tamHats'
  732.    info       = 'Percussive sound somewhere between tam-tam and high-hat.'
  733.    pmtrFields = 8 # this is the base number
  734.    pmtrInfo   = {
  735.                  'pmtr7'   : 'iparm', 
  736.                  'pmtr8'   : 'low pass filter frequency',   
  737.                 } # holds discription, preset for each pmtr in a dictionary
  738.    default    = {
  739.                  'rhythmQ' : ((16, 1), (4, 2)) ,
  740.                  'octQ'    : ([7,8], 'randomChoice'), 
  741.                  'ampQ'    : (60,70, 4, 'linearDown')  ,
  742.                  'panQ'    : (.20, .60, .08, 'linearDown'), 
  743.                  'pmtr7'   : (.1, .9, .1, 'linearUp'), 
  744.                  'pmtr8'   : (800, 16000, 200, 'linearDown'),   
  745.                 } 
  746.    author     = '' # attribution
  747.    orcCode = '''
  748. instr 10
  749.    idur   = p3
  750.    iamp   = ampdb(p4)
  751.    ifrq   = cpspch(p5)
  752.    ipan   = p6
  753.    iparm  = p7
  754.    ilp_fq = p8
  755.    
  756.    k1 linseg    1, (.1*p3), .7, (.5*p3), .7, (.4*p3), 0
  757.    
  758.    ;                 kamp, kcps,        icps, ifn, imeth iparm
  759.    ;                                               decay  0-1,
  760.    a1 pluck     iamp, ifrq,          ifrq,     0,   3,    iparm
  761.    a2 pluck     iamp, (ifrq * .51),  ifrq*.51, 0,   3,    iparm
  762.    a4 pluck     iamp, (ifrq * .24),  ifrq*.24, 0,   3,    iparm
  763.    
  764.    ;master mix
  765.    a3 = ((a1 + a2 + a4) * k1)
  766.    a6 tone a3, ilp_fq
  767.    aMixSig         = (a6 * 2) 
  768. '''
  769.    scoSample = '''
  770. ;ins start  dur   amp   fq    pan  type  low pass  
  771. ;hats                                       fq
  772. i14  0.000  0.100 95  8.02    .1   .6   16000
  773. ;tam tam
  774. i14  3.000  8.000 95  7.10    0    .2   1200
  775. '''
  776.  
  777. #-----------------------------------------------------------------||||||||||||--
  778. class instr11(instrShell):
  779.    inumber     = 11
  780.    name       = 'noise'
  781.    info       = 'A noisy instrument.'
  782.    pmtrFields = 6 # this is the base number
  783.    pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  784.    default    = {
  785.                  'rhythmQ' : ((16, 1), (4, 1)) ,
  786.                  'octQ'    : ([7,8], 'randomChoice'), 
  787.                  'ampQ'    : (60,70, 1, 'linearUp'),
  788.                  'panQ'    : (.20, .80, .08, 'linearUpDown'),   
  789.                 } 
  790.    author     = 'athenaCL native' # attribution
  791.    orcCode = '''
  792. instr 11
  793.    idur   = p3
  794.    iamp   = ampdb(p4)
  795.    iwhite = cpspch(p5)
  796.    ipan   = p6
  797.    a1    rand    iwhite
  798.    k1    linen   iamp, .5, idur, .2
  799.    aMixSig         = (k1 * a1)
  800. '''
  801.    scoSample = '''
  802. '''
  803.  
  804. #-----------------------------------------------------------------||||||||||||--
  805. class instr12(instrShell):
  806.    inumber     = 12
  807.    name       = 'noiseFiltered'
  808.    info       = 'A noisy instrument with with a filter.'
  809.    pmtrFields = 8 # this is the base number
  810.    pmtrInfo   = {
  811.                  'pmtr7'   : 'filter center frequency',
  812.                  'pmtr8'   : 'filter bandwidth',
  813.                 } # holds discription, preset for each pmtr in a dictionary
  814.    default    = {
  815.                  'rhythmQ' : ((16, 1), (16, 5)) ,
  816.                  'octQ'    : ([7,8], 'randomChoice'), 
  817.                  'ampQ'    : (50,60, .5, 'linearDown')  ,
  818.                  'panQ'    : (.20, .60, .08, 'linearDown'), 
  819.                  'pmtr7'   : (400, 800, 20, 'linearUpDown'), 
  820.                  'pmtr8'   : (1, 5, .2, 'linearUpDown'),
  821.                 }
  822.    author     = 'athenaCL native' # attribution
  823.    orcCode = '''
  824. instr 12
  825.    ;duration  = p3
  826.    iamp   = ampdb(p4)
  827.    ifreq  = cpspch(p5)
  828.    ipan   = p6
  829.    ;filter cf  = p7
  830.    ;filter bw  = p8
  831.    
  832.    k1   linen   1,    (p3*.9), p3, (p3*.1)
  833.    
  834.    ;create noise
  835.    ;            amp    freq           
  836.    a1   randi   p4,    p5,             
  837.    
  838.    ;create band pass filter
  839.    ;            signal, filter cf, filter bw         
  840.    a2   reson   a1, p7, p8
  841.  
  842.    aMixSig         = (k1 * a2)
  843. '''
  844.    scoSample = '''
  845. ;ins   strt  dur   amp  fq    pan    fltr   fltr  
  846. ; 56               0-1               cf     bw    
  847. i56   00.0   2.0   .9  10000 .2     440     2    
  848. '''
  849.  
  850. #-----------------------------------------------------------------||||||||||||--
  851. class instr13(instrShell):
  852.    inumber     = 13
  853.    name       = 'rezzySynth'
  854.    info       = 'A highly resonated synth sound.'
  855.    pmtrFields = 9 # this is the base number
  856.    pmtrInfo   = {
  857.                  'pmtr7'   : 'fq sweep (ms time or fq?)',
  858.                  'pmtr8'   : 'irez',
  859.                  'pmtr9'   : 'itabl1 (f-table to choose from)',
  860.                 } # holds discription, preset for each pmtr in a dictionary
  861.    default    = {
  862.                  'rhythmQ' : ('binaryAccent', ((12,1,1),(3,1,1))) ,
  863.                  'octQ'    : ('basketGen', 'randomChoice', (5,6,7)), 
  864.                  'ampQ'    : ('cyclicGen', 'linearDown', 60.00, 76.00, 2.00),
  865.                  'panQ'    : ('cyclicGen', 'linearDown', 0.20, 0.60, 0.08), 
  866.                  'pmtr7'   : ('cyclicGen', 'linearUpDown', 20.00, 8000.00, 40.00),
  867.                  'pmtr8'   : ('cyclicGen', 'linearUpDown', 1.00, 20.00, 1.20),
  868.                  'pmtr9'   : ('cyclicGen', 'linearUpDown', 4, 5, 1),  
  869.                 }
  870.    author     = '' # attribution
  871.    orcCode = '''
  872. instr 13
  873.    idur   = p3
  874.    iamp   = ampdb(p4)
  875.    ifqc   = cpspch(p5)
  876.    ipan   = p6
  877.    
  878.    ; p7 = fq sweep
  879.    irez   = p8
  880.    itabl1 = p9
  881.    
  882.    ; Amplitude envelope
  883.    kaenv  linseg 0, .01, 1, p3-.02, 1, .01, 0
  884.    
  885.    ; Frequency Sweep
  886.    kfco linseg p7, .5*p3, .2*p7, .5*p3, .1*p7
  887.    
  888.    ; This relationship attempts to separate Freq from Res.
  889.    ka1 = 100/irez/sqrt(kfco)-1
  890.    ka2 = 1000/kfco
  891.    
  892.    ; Initialize Yn-1 & Yn-2 to zero
  893.    aynm1 init 0
  894.    aynm2 init 0
  895.    
  896.    ; Oscillator            last number here is the table number
  897.    axn oscil iamp, ifqc, itabl1
  898.    
  899.    ; Replace the differential eq. with a difference eq.
  900.    ayn = ((ka1+2*ka2)*aynm1-ka2*aynm2+axn)/(1+ka1+ka2)
  901.    
  902.    atemp tone axn, kfco
  903.    aclip1 = (ayn-atemp)/100000
  904.    aclip tablei aclip1, 13, 1, .5
  905.    aout = aclip*20000+atemp
  906.    
  907.    aynm2 = aynm1
  908.    aynm1 = ayn
  909.    
  910.    aMixSig = (kaenv*aout)
  911. '''
  912.    scoSample = '''
  913. ;ins start  dur   amp   fq    pan      fq_sweep   irex, itabl1
  914. '''
  915.  
  916. #-----------------------------------------------------------------||||||||||||--
  917. class instr20(instrShell):
  918.    inumber     = 20
  919.    name       = 'fmBasic'
  920.    info       = 'A basic FM instrument.'
  921.    pmtrFields = 8 # this is the base number
  922.    pmtrInfo   = {
  923.                  'pmtr7'   : 'fm factor',
  924.                  'pmtr8'   : 'modulation index',
  925.                 } # holds discription, preset for each pmtr in a dictionary
  926.    default    = {
  927.                  'rhythmQ' : ('binaryAccent', ((7,1,1),(7,5,1))) ,
  928.                  'octQ'    : ('basketGen', 'randomChoice', (7,8)), 
  929.                  'ampQ'    : ('cyclicGen', 'linearDown', 60.00, 76.00, 2.00) ,
  930.                  'panQ'    : ('cyclicGen', 'linearDown', 0.20, 0.60, 0.08), 
  931.                  'pmtr7'   : ('cyclicGen', 'linearUpDown', 0.01, 8.00, 0.10),
  932.                  'pmtr8'   : ('cyclicGen', 'linearUpDown', 1.00, 6.00, 0.10),
  933.                  }
  934.    author     = '"basicfm.orc" from Csound Book examples' # attribution
  935.    orcCode = '''
  936. instr 20
  937.    ipan      =         p6
  938.    iamp      =         ampdb(p4)
  939.    i1        =         1/p3                 ; ONE CYCLE PER DURATION OF NOTE
  940.    i2        =         cpspch(p5)           ; CONVERTS PCHCLASS NOTATION TO Hz
  941.    
  942.    i3        =         i2 * p7          ; i3 IS THE MODULATING FREQUENCY
  943.    i4        =         i3 * p8          ; i4 IS THE MAXIMUM FREQUENCY DEVIATION
  944.    
  945.    ampenv    oscil     iamp,i1,201     ; AMPLITUDE ENVELOPE FOR THE CARRIER
  946.    ampdev    oscil     i4,i1,201       ; ENVELOPE APPLIED TO FREQUENCY DEVIATION
  947.    amod      oscili    ampdev,i3,203              ; MODULATING OSCILLATOR
  948.    asig      oscili    ampenv,i2+amod,203         ; CARRIER OSCILLATOR
  949.  
  950.    aMixSig   = asig
  951.  
  952. '''
  953.    scoSample = '''
  954. ;p1    p2    p3     p4    p5          p6     p7          p8
  955. ;inst  start dur   amp    PCH         pan 
  956. ;      start dur   amp    carrierFQ          fm_factor   mod_index
  957. ;i1      1   5     70     7.06        .5     1           4
  958. ;i1      7   5            7.06        .5     1.414  
  959. '''
  960.  
  961. #-----------------------------------------------------------------||||||||||||--
  962. class instr21(instrShell):
  963.    inumber    = 21
  964.    name       = 'fmClarinet'
  965.    info       = 'A FM instrument tuned to sound clarinet-like.'
  966.    pmtrFields = 7 # this is the base number
  967.    pmtrInfo   = {
  968.                  'pmtr7'   : 'imax value',
  969.                 } # holds discription, preset for each pmtr in a dictionary
  970.    default    = {
  971.                  'rhythmQ' : ('binaryAccent', ((7,3,1),(7,5,1)) ),
  972.                  'octQ'    : ('basketGen', 'randomChoice', (6,7)), 
  973.                  'ampQ'    : ('cyclicGen', 'linearDown', 60.00, 70.00, 1.00) ,
  974.                  'panQ'    : ('cyclicGen', 'linearDown', 0.20, 0.60, 0.08), 
  975.                  'pmtr7'   : ('cyclicGen', 'linearUpDown', 1.50, 6.00, 0.20),
  976.                 }
  977.    author     = '''
  978. FMclarinet.orc from amsterdam catalog
  979. ACCCI:     20_10_4.ORC
  980. synthesis: FM(20),
  981.            FM with dynamic spectral evolution (10)
  982.            clarinet settings(3)
  983. source:    Chowning (1973)
  984. coded:     jpg 8/92
  985. ''' # attribution
  986.    orcCode = '''
  987. instr 21
  988.    idur   = p3
  989.    iamp   = ampdb(p4)
  990.    ifenv  = 211                    ; clarinet settings:
  991.    ifdyn  = 212                    ; amp and index envelope see flow chart
  992.    ifq1   = cpspch(p5)*3          ; N1:N2 is 3:2, imax=5
  993.    if1    = 210                     ; duration ca. .5 sec
  994.    ifq2   = cpspch(p5)*2
  995.    if2    = 210
  996.    imax   = p7
  997.    imin   = 2
  998.    ipan   = p6
  999.  
  1000.    aenv  oscili   iamp, 1/idur, ifenv                ; envelope
  1001.  
  1002.    adyn  oscili   ifq2*(imax-imin), 1/idur, ifdyn    ; index
  1003.    adyn  =        (ifq2*imin)+adyn                   ; add minimum value
  1004.    amod  oscili   adyn, ifq2, if2                    ; modulator
  1005.  
  1006.    a1    oscili   aenv, ifq1+amod, if1               ; carrier
  1007.  
  1008.    aMixSig         = a1
  1009.  
  1010. '''
  1011.    scoSample = '''
  1012. ;p1    p2    p3     p4    p5     p6     p7   
  1013. ;inst  start dur   amp    PCH    pan 
  1014. ;            idur iamp   pch            imax
  1015. i1    0     .5    75     8.00          4        ; scale by clarinet
  1016. i1    +     .     .      8.02          .
  1017. i1    .     .     .      8.04          .
  1018. '''
  1019.  
  1020. #-----------------------------------------------------------------||||||||||||--
  1021. class instr22(instrShell):
  1022.    inumber    = 22
  1023.    name       = 'fmWoodDrum'
  1024.    info       = 'A FM instrument tuned to sound wood-drum-like.'
  1025.    pmtrFields = 6 # this is the base number
  1026.    pmtrInfo   = {} # holds discription, preset for each pmtr in a dictionary
  1027.    default    = {
  1028.                  'rhythmQ' : ('loop', ((8,3,1),(8,3,1),(8,3,1),(8,1,0),(4,1,1),(4,1,1),(8,1,1),(8,1,0))) ,
  1029.                  'octQ'    : ('basketGen', 'randomChoice', (2,2)), 
  1030.                  'ampQ'    : ('cyclicGen', 'linearDown', 80.00, 81.00, 1.00) ,
  1031.                  'panQ'    : ('cyclicGen', 'linearDown', 0.20, 0.60, 0.08), 
  1032.                 }
  1033.    author     = '''
  1034. FMwoodDrum.orc from amsterdam catalog
  1035. ACCCI:     20_10_2.ORC
  1036. synthesis: FM(20),
  1037.            FM with dynamic spectral evolution (10)
  1038.            wood-drum settings(2)
  1039. source:    Chowning(1973)
  1040. coded:     jpg 8/92
  1041. ''' # attribution
  1042.    orcCode = '''
  1043. instr 22
  1044.    idur   = p3
  1045.    iamp   = ampdb(p4)
  1046.    ifenv  = 251                    ; wood drum settings:
  1047.    ifdyn  = 231                    ; amp and index envelopes see flow chart
  1048.    ifq1   = cpspch(p5)*16           ; N1:N2 is 80:55 = 16:11, imax=25
  1049.    if1    = 210                     ; duration = .2 sec
  1050.    ifq2   = cpspch(p5)*11
  1051.    if2    = 210                     ; same gen used by clar
  1052.    imax   = 25
  1053.    ipan   = p6
  1054.    
  1055.    aenv  oscili   iamp, 1/idur, ifenv             ; envelope
  1056.    adyn  oscili   ifq2*imax, 1/idur, ifdyn        ; dynamic
  1057.    amod  oscili   adyn, ifq2, if2                 ; modulator
  1058.    a1    oscili   aenv, ifq1+amod, if1            ; carrier
  1059.  
  1060.    aMixSig = a1
  1061. '''
  1062.    scoSample = '''
  1063. ;p1    p2    p3     p4    p5     p6     p7   
  1064. ;inst  start dur   amp    PCH    pan 
  1065. ;            idur  iamp   pch
  1066. ;i1    0     .2     76    3.00   .5  ; scale in wood drum...
  1067. ;i1    +     .     .      3.02    .
  1068. '''
  1069.  
  1070. #-----------------------------------------------------------------||||||||||||--
  1071. class instr30(instrShell):
  1072.    inumber     = 30
  1073.    name       = 'samplerUni'
  1074.    info       = 'A simple sampler that plays any number of single audio files. Audio files are given with a complete file path.'
  1075.    pmtrFields = 12 # this is the base number
  1076.    pmtrInfo   = {
  1077.                  'pmtr7'   : 'skip time',
  1078.                  'pmtr8'   : 'atack',
  1079.                  'pmtr9'   : 'release',
  1080.                  'pmtr10'  : 'reverb time',
  1081.                  'pmtr11'  : 'reverb gain',
  1082.                  'pmtr12'  : 'file path chooser',
  1083.                 } # holds discription, preset for each pmtr in a dictionary
  1084.    default    = {
  1085.                  'rhythmQ' : ('binaryAccent', ((9,6,1),(9,2,1)) ), 
  1086.                  'octQ'    : ('basketGen', 'randomChoice', (7,8)),
  1087.                  'ampQ'    : ('cyclicGen', 'linearDown', 2.00, 9.00, 0.25) ,
  1088.                  'panQ'    : ('cyclicGen', 'linearDown', 0.30, 0.70, 0.08), 
  1089.                  'pmtr7'   : ('constant', 0),
  1090.                  'pmtr8'   : ('cyclicGen', 'linearUp', .03, .10, .01),
  1091.                  'pmtr9'   : ('constant', 0.1),
  1092.                  'pmtr10'  : ('cyclicGen', 'linearUp', .5, 2.1, .2),
  1093.                  'pmtr11'  : ('cyclicGen', 'linearUp', .00, .50, .05),
  1094.                  'pmtr12'  : ('sampleSelect', ('drum01.aif', 'latch01.aif')),
  1095.                 }
  1096.    author     = 'athenaCL native' # attribution
  1097.    orcCode = '''
  1098. instr 30
  1099.    idur = p3
  1100.    iamp  = ampdb(p4)
  1101.    ifreq  = cpspch(p5)
  1102.  
  1103.    ipitch      = .5
  1104.    ipan        = p6
  1105.    iskiptime   = p7
  1106.    iattack     = p8
  1107.    irelease    = p9
  1108.    irvbtime    = p10
  1109.    irvbgain    = p11
  1110.    ;use full pathnames for samples
  1111.    iSamplePath = p12  ; selects which sample
  1112.                   
  1113.    kamp        linen     iamp, iattack, idur, irelease
  1114.    asig        soundin   iSamplePath, iskiptime
  1115.  
  1116.    ;this doesnt work yet
  1117.    ;asig       diskin    iSamplePath, ipitch, iskiptime, 0
  1118.  
  1119.    arampsig   = kamp * asig
  1120.    aeffect      reverb  asig, irvbtime
  1121.    arvbreturn = aeffect * irvbgain
  1122.  
  1123.    aMixSig    =  arampsig + arvbreturn
  1124. '''
  1125.    scoSample = '''
  1126. ; ins   strt    dur     amp(db) p5(pch) p6(pan) skip    atk     rel     rvbt    rvbgain  samplePath
  1127. i8   0       1       20      8.0     .0      0       .03     .1      1.5     .2       "/athenaCL/ATHssdir/drum01.aif"
  1128. i8   2       1       20      8.0     .3      0       .8      .1      1.3     .5       "/athenaCL/ATHssdir/drum01.aif"
  1129. i8   3.5     2.25    20      8.0     .5      0       .5      .1      2.1     .2       "/athenaCL/ATHssdir/latch01.aif"
  1130. '''
  1131.  
  1132. #-----------------------------------------------------------------||||||||||||--
  1133. class instr40(instrShell):
  1134.    inumber    = 40
  1135.    name       = 'pvocUni'
  1136.    info       = 'A simple pvoc instrument.'
  1137.    pmtrFields = 7
  1138.    pmtrInfo   = {
  1139.                  'pmtr7'   : 'pvc analysis file to use',
  1140.                 } # holds discription, preset for each pmtr in a dictionary
  1141.    default    = {
  1142.                  'rhythmQ' : ('loop', ((5, 6, 1), (5, 2, 0), (5, 11, 1), (5, 3, 1))), 
  1143.                  'octQ'    : ('basketGen', 'randomChoice', [7,8]),
  1144.                  'ampQ'    : ('cyclicGen', 'linearDown', 2.00, 9.00, 0.25),
  1145.                  'panQ'    : ('cyclicGen', 'linearDown', 0.30, 0.70, 0.08), 
  1146.                  'pmtr7'   : ('analysisSelect', ('drum01.pvc',)),
  1147.                 }
  1148.    author     = 'athenaCL native' # attribution
  1149.    orcCode = '''
  1150. instr 40
  1151.    idur  = p3
  1152.    iamp  = ampdb(p4)
  1153.    ifreq = cpspch(p5)
  1154.    ipan  = p6
  1155.  
  1156.    iAnalysisPath = p7  ;use full pathnames for analysis files
  1157.  
  1158.    kEnvelope      linseg  0, .05, 1, (p3-.10), 1, .05, 0     ;quick envelope
  1159.  
  1160.    kTimePosition  line   0, p3, p3      ;error if this is too large
  1161.    kFqMod         line   1, p3, 1
  1162.  
  1163.    asig           pvoc    kTimePosition, kFqMod, iAnalysisPath
  1164.  
  1165.    aMixSig =  kEnvelope * asig
  1166. '''
  1167.    scoSample = '''
  1168. '''
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.